package demo1;

public class Computer {
    public void open() {
        System.out.println("打开笔记本");
    }
    public void close() {
        System.out.println("关闭笔记本");
    }
    public void use(IUSB iusb) {
        iusb.openDevice();
        if (iusb instanceof Mouse) {
            Mouse mouse = (Mouse) iusb;
            mouse.click();
        } else if (iusb instanceof Keyboard) {
            Keyboard keyboard = (Keyboard) iusb;
            keyboard.inPut();
        }
        iusb.closeDevice();
    }

    public static void main(String[] args) {
        Computer computer = new Computer();
        computer.open();
        computer.use(new Mouse());
        computer.use(new Keyboard());
        computer.close();
    }
}
